import java.sql.*;

public class MysqlConnect {
	public static void main(String[] args) {
		  System.out.println("MySQL Connect Example.");
		  Connection conn = null;
		  String url = "jdbc:mysql://localhost:3306/";
		  String dbName = "pichubdb";
		  String driver = "com.mysql.jdbc.Driver";
		  String userName = "pichub"; 
		  String password = "Mark1990";
		  try {
			  System.err.println("1");
		  Class.forName(driver).newInstance();
		  System.err.println("2");
		  conn = DriverManager.getConnection(url,userName,password);
		  System.err.println("3");
		  System.out.println("Connected to the database");
		  System.err.println("4");
		  conn.close();
		  System.out.println("Disconnected from database");
		  } catch (Exception e) {
			  System.out.println("Failed to connect to database");
		  e.printStackTrace();
		  }
	}
}
